package hb.software.holiday.service.impl;

import java.util.List;
import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
import org.springframework.stereotype.Service;
import hb.software.holiday.dao.HolidayDao;
import hb.software.holiday.domain.Holiday;
import hb.software.service.impl.GenericManagerImpl;
import hb.software.holiday.service.HolidayManager;

/**
 * 
 * @ClassName: HolidayManagerImpl
 * @Description: Crud's service of Holiday module
 * @author XuHuang
 * @date May 28, 2020 9:47:14 PM
 *
 */

@Service("holiday")
@Transactional
public class HolidayManagerImpl extends GenericManagerImpl<Holiday, Long> implements HolidayManager {

	HolidayDao holidayDao;
    @Autowired
    public void setHolidayDao(HolidayDao holidayDao) {
    	this.holidayDao = holidayDao;
    	this.dao=this.holidayDao;
    }
	public List<Holiday> findByName(String name) {

		Holiday queryObject = new Holiday();
		queryObject.setName(name);
		ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("name", GenericPropertyMatchers.startsWith())
				.withIgnorePaths("dateCreated", "dateModified");

		Example<Holiday> ex = Example.of(queryObject, matcher);
		List<Holiday> result = dao.findAll(ex);
		return result;
	}

}
